package com.itmiaojie.controller;

import com.itmiaojie.pojo.Comment;
import com.itmiaojie.pojo.ResponseResult;
import com.itmiaojie.service.CommentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/comment")
@Api(tags = "评论",description = "评论相关接口")
public class CommentController {

    @Autowired
    private CommentService commentService;

    @GetMapping("/commentList")
    public ResponseResult commentList(Long articleId, Integer pageNum, Integer pageSize) throws InstantiationException, IllegalAccessException {
        return commentService.commentList("0", articleId,pageNum,pageSize);
    }

    @PostMapping
    public ResponseResult addComment(@RequestBody Comment comment){
        return commentService.addComment(comment);
    }
    @GetMapping("/linkCommentList")
    @ApiOperation(value = "友联评论列表",notes = "获取一页友联评论列表")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "页号",name = "pageNum"),
            @ApiImplicitParam(value = "每页大小",name = "pageSize")}
    )
    public ResponseResult linkCommentList(Integer pageNum,Integer pageSize) throws InstantiationException, IllegalAccessException {
        return commentService.commentList("1", null, pageNum, pageSize);
    }
}
